package com.treasure.mall.biz.entity.order;

import com.treasure.mall.biz.entity.BasePO;
import com.treasure.mall.biz.entity.user.UserPO;
import com.treasure.mall.zbq.common.constant.Constant;
import com.treasure.mall.zbq.common.ienum.order.OrderEnums;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/6/13
 */
@MappedSuperclass
@Setter
@Getter
public class OrderPO extends BasePO {
    @Id
    @Column(name = "id", length = 30)
    protected String orderId;
    /**
     * 买家
     */
    @ManyToOne
    @JoinColumn(name = "rel_user_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    protected UserPO userPO;
    /**
     * 最终金额
     */
    @Column(name = "final_amount", scale = 2, precision = 10)
    protected BigDecimal finalAmount;

    /**
     * 剩余需要支付的金额
     */
    @Column(name = "surplus_amount", scale = 2, precision = 10)
    protected BigDecimal surplusAmount;

    /**
     * 支付状态
     * {@link com.treasure.mall.zbq.common.ienum.order.OrderEnums.PayStatus}
     */
    @Column(name = "pay_status")
    protected OrderEnums.PayStatus payStatus;
    /**
     * 支付类型
     */
    @Column(name = "pay_type")
    protected OrderEnums.PayType payType;

    /**
     * 支付时间
     */
    @Column(name = "pay_time", columnDefinition = Constant.DATE_COLUMN_DEFINITION)
    protected LocalDateTime payTime;

    /**
     * 支付超时时间
     */
    @Column(name = "pay_expire_time", columnDefinition = Constant.DATE_COLUMN_DEFINITION)
    protected LocalDateTime payExpireTime;
}
